//
//  DownLoad.h
//  Slice
//
//  Created by lanou on 16/6/23.
//  Copyright © 2016年 wangjinchao. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DownLoaderTableViewCell.h"

typedef void(^block)(int64_t currentMB, int64_t totalMB);



//下载完成通知
#define downLoadFinishNotification @""
@interface DownLoad : NSObject<NSURLSessionDownloadDelegate>
//下载地址
@property (nonatomic,copy) NSString *urlString;
//保存路经
@property (nonatomic, copy) NSString *saveFileName;

//下载所需的
@property (nonatomic, retain) NSURLSessionDownloadTask *downLoadTask;


//声明block 对外穿当前的总值和当前的值 回调函数
@property (nonatomic, copy) block  sendValue;

@property (nonatomic, assign) BOOL isLoading;

//当前进度
@property (nonatomic, assign) CGFloat proportion;

//下载类的封装
- (instancetype)initWithURL:(NSString *)URLString saveNameL:(NSString *)saveFileName;

//下载开始的方法
- (void)beginLoad;

//取消下载
- (void)cancel;

//暂停下载
- (void)pause;

@end


typedef enum {
    
    addResultSuccess,//添加成功
    addResultDownLoading,//正在下载中
    addResultLoadFinish //下载完成
}addResult;






//下载管理类
@interface DownLoadMaqnager : NSObject

@property (nonatomic, strong) NSMutableArray *URLArray;

@property (nonatomic, strong) NSMutableArray *taskArray;

//单例
+ (instancetype)shareInstace;


//添加一个下载任务保存文件名称 添加结果
- (DownLoad *)addDownLoadWithURL:(NSString *)urlString saveFileName:(NSString *)saveFileName addResult:(void(^)(addResult addResult))resultCallBack;




@end
